#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : gtmsAutoTestProject 
@File    : member_info_server.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/7/23 9:46 
@Describe: 会员信息业务实现
"""
from Comm.tools.toolsControl import ToolsHandler
from APIs.middleApi.customer.customer_api import CustomerApi
from FastApi.enum.Interface_enum.error_enum import ERROR_ENUM


def get_customer_info(brandCode, environment, phone):
    """
    获取会员信息
    :param brandCode: 品牌编码
    :param environment: 环境
    :param phone: 手机号
    :return:
    """
    customer_requests = CustomerApi(environment)
    response = customer_requests.get_customer_list(brandCode, phone)
    customer_info = ToolsHandler.get_json_result(response, '$.data.list')
    if not customer_info:
        result_info = {"code": ERROR_ENUM.MEMBER_NO_EXISTENT.value[0], "message": ERROR_ENUM.MEMBER_NO_EXISTENT.value[1]}
        return result_info
    else:
        result_info = {"code": 200, "message": "获取会员信息成功~", "data": customer_info}
        return result_info
